<template>
	<view class="group">
		<view class="bg6c mt11 mx15">
			<image class="bgImg r6" src="/static/img/bg/card_bg2.png" mode="aspectFill"></image>
			<view class="box pt14 px9">
				<view class="flex flexC fs13">
					<view class="flex1">我的积分</view>
					<view class="flex flexC mr12">
						<text>积分使用明细</text>
						<uni-icons type="right" size="14" color="#6F3D00"></uni-icons>
					</view>
				</view>
				<view class="mt10 flex flexC">
					<text class="fs21 bold6">100</text>
					<view class="flex flexC pt5">
						<text class="fs10 mx4">积分使用规则</text>
						<uni-icons type="help-filled" size="16" color="#6F3D00"></uni-icons>
					</view>
				</view>
			</view>
			
			<scroll-view scroll-y class="bgf5 c00" :style="{height: 'calc(100vh - 156rpx - ' + statusBar + 'px)'}">
				<view class="flex flexC flexB c99 fs16 px10 py6 bgff px15">
					<view class="pt8 pb4 item" @click="switchTab(index)" v-for="(item,index) in tabs" :key="index" :class="index==currentTab?'active':''">
						<text>{{item}}</text>
						<image v-if="currentTab == index" class="icon" src="/static/img/icon/sel.png" mode="widthFix"></image>
					</view>
				</view>
				
			
			</scroll-view>
			
			
		</view>
	</view>
	
	
	
</template>

<script>
	export default {
		name:"mall",
		props: {
			statusBar: {
				type: Number,
				default: 20
			},
		},
		data() {
			return {
				isChecked: false,
				page:1,
				list:[],
				check:false,
				tabs: ['全部','小侠力荐','热销品'],
				currentShopRoom:[]
			};
		},
		
		methods: {
			
			buy(item){
				let param = {
					id:item.id,
				};
				let that = this;
				this.$api.addTuanOrder(param).then(res => {
					if (res.code == 1) {
				
						that.wechatPay(res.data.payInfo)

					} else {
						uni.showToast({
							icon:'none',
							title:res.msg
						})
					}
				})
			},
			
			
			wechatPay(payConfig) {
				let that = this;
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: payConfig.timeStamp,
					nonceStr: payConfig.nonceStr,
					package: payConfig.package,
					signType: payConfig.signType,
					paySign: payConfig.paySign,
					success: function(res) {
						
						uni.showModal({
							title:"购买提示",
							content:"购买成功赶紧使用吧",
							showCancel:false,
							complete() {
								
							}
						})
					},
					fail: function(err) {
						uni.showToast({
							title: "取消购买",
							icon: 'none'
						});
					}
				});
			},
			
			openItem(item){
				
				// for(var i=0;i<this.list.length;i++){
				// 	this.list[i].check = false;
				// }
				this.currentShopRoom = item.rooms;
				this.check = !this.check;
		
			},
			look(item){
				this.$refs.popup.open();
				
				
			},
			take(item){
				let param = {
					id: item.id,
				};
				let that = this;
				this.$api.takeCoupon(param).then(res => {
					if (res.code == 1) {
				
						item.is_take = 1;
				
					} 
					uni.showToast({
						icon: 'none',
						title: res.msg
					})
				})
			},
			getData(selectShop) {
				
				let param = {
					shop_id:selectShop.id,
					page:this.page
				};
				let that = this;
				this.$api.shopCouponList(param).then(res => {
					console.info(JSON.stringify(res));
					if (res.code == 1) {
						that.list = res.data;
					} else {
				
					}
				})
				console.log(selectShop)
				// this.$nextTick(() => {
				// 	this.$refs.popup.open();
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
.group {
	.bgImg {
		width: 100%;
		height: 160rpx;
		position: relative;
		z-index: 1;
	}
	.bg6c {
		color: #6F3D00;
		position: relative;
		.box {
			width: 100%;
			position: absolute;
			top: 0;
			height: 160rpx;
			z-index: 9;
		}
	}
}

</style>